package tcpdemo.tcptest1;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        // 创建服务器
        ServerSocket ss = new ServerSocket(10000);
        // 等待客户端连接
        Socket accept = ss.accept();
        // 获取输出流
        InputStream is = accept.getInputStream();
        int b;
        while ((b = is.read())!= -1){
            System.out.println((char)b);
        }
        /*OutputStream os = accept.getOutputStream();
        os.write("你是谁".getBytes());*/
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
        bw.write("你是谁?");
        bw.newLine();
        bw.flush();


        bw.close();
        ss.close();
        accept.close();
        is.close();
    }
}
